package project01;
/**
 * Title: Part1 class for CSIS 235 Project 1
 * Description: CS 235 Project #1 - Part 1
 *              Basic program used to ask the user for age values and
 *              compute and print the average.
 * @author Anthony Varghese
 * @email  anthony.varghese@uwrf.edu
 * @date   January 24th 2012
 */

public class Part1Done {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.print("Enter the number of people in your family: ");
		
		final java.util.Scanner console_input = new java.util.Scanner( System.in );
		final int NUMBER_OF_PEOPLE = Integer.parseInt( console_input.next() );
		
		int[] ages = new int[ NUMBER_OF_PEOPLE ];
		
		for( int i=0; i<NUMBER_OF_PEOPLE; i++ ){
			System.out.print(" Enter the age of person #" + (i+1) + ": " );
			ages[i] = Integer.parseInt( console_input.next() );
		}
		System.out.println("-----------------------------------------------------------------");
		
		int sum_of_ages = 0;
		for (int age: ages )
			sum_of_ages += age;
		
		final float average = (float) sum_of_ages / NUMBER_OF_PEOPLE;
		System.out.printf("The average age of all the people in your family is: %.2f\n", average);
		System.out.println("------------------- done! ---------------------------------------");
	}
}
